package net.huashitong.ssydt.provider.exam.service;


import net.huashitong.ssydt.exam.entity.SsExamCollectionQuestion;
import net.huashitong.ssydt.exam.entity.vo.QuestionCollectionListOutVO;
import net.huashitong.ssydt.exam.entity.vo.QuestionErrorCollectionListInVO;
import net.huashitong.ssydt.provider.exam.mapper.SsExamCollectionQuestionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.09.12
 */
@Service
@Transactional
public class SsExamCollectionQuestionServiceImpl implements SsExamCollectionQuestionService {

    private SsExamCollectionQuestionMapper mapper;

    @Autowired
    public SsExamCollectionQuestionServiceImpl(SsExamCollectionQuestionMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SsExamCollectionQuestion record) {
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(SsExamCollectionQuestion record) {
        return mapper.insertSelective(record);
    }

    @Override
    public SsExamCollectionQuestion selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SsExamCollectionQuestion record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SsExamCollectionQuestion record) {
        return mapper.updateByPrimaryKey(record);
    }

    @Override
    public List<QuestionCollectionListOutVO> countGroupByBelongYearMonthByUserId(
            QuestionErrorCollectionListInVO questionErrorCollectionListInVO) {
        return mapper.countGroupByBelongYearMonthByUserId(questionErrorCollectionListInVO);
    }

    @Override
    public List<SsExamCollectionQuestion> findByUserIdWithBelongYearMonth(String userId, String belongYearMonth) {
        SsExamCollectionQuestion ssExamCollectionQuestion = new SsExamCollectionQuestion();
        ssExamCollectionQuestion.setBelongYearMonth(belongYearMonth);
        ssExamCollectionQuestion.setUserId(userId);
        return mapper.findByUserIdWithBelongYearMonth(ssExamCollectionQuestion);
    }

    @Override
    public void deleteByUserId(String userId) {
        mapper.deleteByUserId(userId);
    }

    @Override
    public SsExamCollectionQuestion getByUserIdWithQuestionId(String userId, Long questionId) {
        SsExamCollectionQuestion ssExamCollectionQuestion = new SsExamCollectionQuestion();
        ssExamCollectionQuestion.setUserId(userId);
        ssExamCollectionQuestion.setQuestionId(questionId);
        return mapper.getByUserIdWithQuestionId(ssExamCollectionQuestion);
    }

    @Override
    public int deleteByUserIdWithQuestionId(String userId, Long questionId) {
        SsExamCollectionQuestion ssExamCollectionQuestion = new SsExamCollectionQuestion();
        ssExamCollectionQuestion.setUserId(userId);
        ssExamCollectionQuestion.setQuestionId(questionId);
        return mapper.deleteByUserIdWithQuestionId(ssExamCollectionQuestion);
    }
}
